﻿using System;
using Ninject;

namespace Machinery
{
    /// <summary>
    /// Helper class in tests, mainly used by test helper methods.
    /// Basically just a static place to keep the kernel, so that we don't have to throw it around.
    /// </summary>
    public static class KernelFinder
    {
        private static IKernel _kernel = null;

        public static void SetKernel(IKernel kernel)
        {
            _kernel = kernel;
        }
        
        public static IKernel Find()
        {
            if (_kernel == null)
                throw new Exception("Kernel not set, must set kernel via SetKernel(). Preferably do this in test SetUp.");
            return _kernel;
        }

        public static void DestroyKernel()
        {
            _kernel = null;
        }
    }
}